// compose(f1, f2, f3) => f1(f2(f3))
// 将一些列函组合成一个嵌套函数调用
export default function compose(...funs) {
  if (funs.length === 0) {
    return (...args) => args;
  }

  if (funs.length === 1) {
    return funs[0];
  }

  return funs.reduce((lastRes, item) => {
    return (...args) => {
      return lastRes(item(...args));
    };
  });
}
